package org.jpush.core.monitor;

import org.jpush.core.AbstractAcceptor;
import org.jpush.core.Server;
import org.jpush.core.socket.JPushClientSocket;
import org.jpush.impl.xml.XMLProtocol;

public class MonitorAcceptor extends AbstractAcceptor
{
	private XMLProtocol protocol;

	public MonitorAcceptor(Server serverImpl)
	{
		super(serverImpl);

	    protocol = new XMLProtocol();

	    // Update the options
	    options.setIsTcpNoDelay(true);
	    //options.setInterfaceAddress(null);
	    options.setListeningBackLog(10);
	    options.setProtocol(protocol);
	    options.setSynAttackPrevention(false);
	    //options.readBufferSize = 8192;
	    //options.sendBufferSize = 8192;
	    options.setIntermediateReceiveBufferSize(8192 * 2);
	    options.setIntermediateSendBufferSize(8192 * 3);
	}

	protected boolean handleAcceptedSocket(JPushClientSocket clientSocket)
	{
		// Send the request to handle and the function will return
		// so that next request could be handled as soon as possible.
		// For monitor request, no statics should be recorded.
	    return server.getChannelFactory().setupDashboardConnection(clientSocket, this);
	}

}
